$(function () {
    $.ajax({
        url : base + "/manage/getPersonalPlanDetailList.action",
        type : "post",
        data : {},
        cache : false,
        success : function(data) {
            if(data!=null){
                var recordTime = ['跑步机','划船器','肌肉组','仰卧器','健步车','美腰机','登梯器','引体杆','瑜伽球'];
                var T111 = [0,0,0,0,0,0,0,0,0];
                var Tgoal =[];
                for(var i=0;i<data.rows.length;i++){
                    if(data.rows[i].ftType==111){
                        T111[0]=data.rows[i].dDuration;
                        Tgoal[0]=data.rows[i].dGoal;
                    }else if(data.rows[i].ftType==222){
                        T111[1]=data.rows[i].dDuration;
                        Tgoal[1]=data.rows[i].dGoal;
                    }else if(data.rows[i].ftType==333){
                        T111[2]=data.rows[i].dDuration;
                        Tgoal[2]=data.rows[i].dGoal;
                    }else if(data.rows[i].ftType==444){
                        T111[3]=data.rows[i].dDuration;
                        Tgoal[3]=data.rows[i].dGoal;
                    }else if(data.rows[i].ftType==555){
                        T111[4]=data.rows[i].dDuration;
                        Tgoal[4]=data.rows[i].dGoal;
                    }else if(data.rows[i].ftType==666){
                        T111[5]=data.rows[i].dDuration;
                        Tgoal[5]=data.rows[i].dGoal;
                    }else if(data.rows[i].ftType==777){
                        T111[6]=data.rows[i].dDuration;
                        Tgoal[6]=data.rows[i].dGoal;
                    }else if(data.rows[i].ftType==888){
                        T111[7]=data.rows[i].dDuration;
                        Tgoal[7]=data.rows[i].dGoal;
                    }else{
                        T111[8]=data.rows[i].dDuration;
                        Tgoal[8]=data.rows[i].dGoal;
                    }
                }
                $('#container').highcharts({

                    chart: {
                        type: 'column'
                    },

                    title: {
                        text: '明日锻炼计划'
                    },

                    xAxis: {
                        categories: recordTime
                    },

                    yAxis: {
                        allowDecimals: false,
                        min: 0,
                        title: {
                            text: '锻炼分钟'
                        }
                    },

                    tooltip: {
                        formatter: function () {
                            return '<b>' + this.x + '</b><br/>' +
                                this.series.name + ': ' + this.y +'分钟'+ '<br/>' +
                                'Total: ' + this.point.stackTotal+'分钟'+ '<br/>'+getGoal(this.x,Tgoal);
                        }
                    },

                    plotOptions: {
                        column: {
                            stacking: 'normal'
                        }
                    },

                    series: [{
                        name: '锻炼时长',
                        data: T111,
                        stack: 'male'
                    }]
                })
            }else{
                return false;
            }
        },
        async : false
    })
});

function getGoal(value,Tgoal){
    if(value=="跑步机"){
        return Tgoal[0];
    }else if(value=="划船器"){
        return Tgoal[1];
    }else if(value=="肌肉组"){
        return Tgoal[2];
    }else if(value=="仰卧器"){
        return Tgoal[3];
    }else if(value=="健步车"){
        return Tgoal[4];
    }else if(value=="美腰机"){
        return Tgoal[5];
    }else if(value=="登梯器"){
        return Tgoal[6];
    }else if(value=="引体杆"){
        return Tgoal[7];
    }else{
        return Tgoal[8];
    }
}

